<div class="content-wrapper">
    <section class="content-header">
        <h1>{$quotedInfo?'编辑':'新增'}报价</h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">报价管理</li>
            <li class="active">{$quotedInfo?'编辑':'新增'}报价</li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-header with-border">
            </div>
            <div class="box-body">
                <form class="form-horizontal" role="form" action="javascrip:;" method="post">
                    <input type="hidden" name="id" id="id" value="{$quotedInfo.id}" />
                    <div class="form-group">
                        <label for="resource" class="col-sm-3 control-label"> 资源 </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="resource" name="resource" value="{$quotedInfo.resource}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="platform" class="col-sm-3 control-label"> 平台 </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="platform" name="platform" value="{$quotedInfo.platform}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="place" class="col-sm-3 control-label"> 位置 </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="place" name="place" value="{$quotedInfo.place}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="put_target" class="col-sm-3 control-label"> 目标-吧 </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="put_target" name="put_target" value="{$quotedInfo.put_target}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="pv" class="col-sm-3 control-label"> PV </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="pv" name="pv" value="{$quotedInfo.pv}"/>
                        </div>
                    </div><div class="form-group">
                        <label for="cpm" class="col-sm-3 control-label"> CPM </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="cpm" name="cpm" value="{$quotedInfo.cpm}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="price" class="col-sm-3 control-label"> 单价 </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="price" name="price" value="{$quotedInfo.price}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="put_time" class="col-sm-3 control-label"> 起投时间 </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="put_time" name="put_time" value="{$quotedInfo.put_time|date='Y-m-d',###}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="put_day" class="col-sm-3 control-label">投放天数 </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="put_day" name="put_day" value="{$quotedInfo.put_day}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="total_price" class="col-sm-3 control-label"> 总价 </label>
                        <div class="col-sm-6">
                            <input class="form-control" id="total_price" name="total_price" value="{$quotedInfo.total_price}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="form-field-1" class="col-sm-3 control-label"></label>
                        <div class="col-sm-6">
                            <button type="button" class="btn btn-info btn-sm save-btn">提交</button>
                            &nbsp;
                            <button type="reset" class="btn btn-sm">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </section>
</div>
<script src="__PUBLIC__/AdminLTE/plugins/layer/layer.js"></script>
<script src="__PUBLIC__/AdminLTE/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script type="application/javascript">
    $(function () {
        //Date picker
        $('#put_time').datepicker({
            language: 'zh-CN',
            format:'yyyy-mm-dd',
            todayHighlight: true,
            autoclose: true
        });
    });
    //提交
    $(".save-btn").click(function () {
        var id = $("#id").val();
        var resource = $("#resource").val();
        var place = $("#place").val();
        var platform = $("#platform").val();
        var pv = $("#pv").val();
        var cpm = $.trim($("#cpm").val());
        var put_target = $.trim($("#put_target").val());
        var put_time = $.trim($("#put_time").val());
        var put_day = $.trim($("#put_day").val());
        var price = $.trim($("#price").val());
        var total_price = $.trim($("#total_price").val());

        if(resource==''){
            layer.msg('请填写资源信息',{time:1000});
            $('#resource').focus();
            return false;
        }if(place==''){
            layer.msg('请填写位置信息',{time:1000});
            $('#place').focus();
            return false;
        }if(platform==''){
            layer.msg('请填写平台信息',{time:1000});
            $('#platform').focus();
            return false;
        }if(pv=='' || isNaN(pv)){
            layer.msg('请填写pv信息',{time:1000});
            $('#pv').focus();
            return false;
        }if(cpm=='' || isNaN(cpm)){
            layer.msg('请填写cpm信息',{time:1000});
            $('#cpm').focus();
            return false;
        }if(put_target==''){
            layer.msg('请填写投放吧信息',{time:1000});
            $('#put_target').focus();
            return false;
        }if(price=='' || isNaN(price)){
            layer.msg('请填写单价',{time:1000});
            $('#price').focus();
            return false;
        }if(put_time==''){
            layer.msg('请填写起投时间',{time:1000});
            $('#put_time').focus();
            return false;
        }if(put_day=='' || isNaN(put_day)){
            layer.msg('请填写投放天数信息',{time:1000});
            $('#put_day').focus();
            return false;
        }if(total_price=='' || isNaN(total_price)){
            layer.msg('请填写总价',{time:1000});
            $('#total_price').focus();
            return false;
        }
        $.post('/admin/quoted/ajaxSaveQuoted',{
            id: id,
            resource: resource,
            platform: platform,
            put_target: put_target,
            place: place,
            pv: pv,
            cpm: cpm,
            put_time: put_time,
            put_day: put_day,
            price: price,
            total_price: total_price
        },function (data) {
            if(data.Code == 999) {
                layer.alert('操作成功',{
                    skin: 'layui-layer-lan'
                    ,closeBtn: 0
                    ,anim: 4 //动画类型
                }, function(){
                    window.location.href = '/admin/quoted/quotedList';
                });
            } else {
                layer.alert(data.Msg,{
                    skin: 'layui-layer-lan'
                    ,closeBtn: 0
                    ,anim: 4 //动画类型
                });
            }
        },"JSON");
    });
</script>